<template>
  <div class="information">
    <titleText title="设置中心"></titleText>
    <div class="title">账号安全</div>
    <div class="set_cell">
      <div class="set_item">
        <img class="icon" src="../../../assets/my/27.png" alt="" />
        <div class="item_text">
          <div class="text_le">
            <div class="text_le_1">绑定手机号</div>
            <div class="text_le_2">已绑定手机：{{ userInfo.mobile }}</div>
          </div>
          <div class="text_ri" @click="editPhone">修改</div>
        </div>
      </div>
      <div class="set_item">
        <img class="icon" src="../../../assets/my/28.png" alt="" />
        <div class="item_text">
          <div class="text_le">
            <div class="text_le_1">登录密码</div>
            <div class="text_le_2">定期更改密码，保护帐户安全</div>
          </div>
          <div class="text_ri" @click="editPassword">修改</div>
        </div>
      </div>
    </div>
    <div class="set_cell" v-if="userInfo.is_bind_wechat == 1">
      <div class="set_item">
        <img class="icon" src="../../../assets/my/29.png" alt="" />
        <div class="item_text">
          <div class="text_le">
            <div class="text_le_1">微信绑定</div>
            <div class="text_le_2">已绑定</div>
          </div>
          <div class="text_ri_unbind" @click="unbindWechat">解绑</div>
        </div>
      </div>
    </div>
  </div>
</template>


<script name="setUp" setup>
import { post661f7a29c8ae2, post662a30c667004 } from "@/utils/api.js";
import titleText from "../titleText.vue";
import { ref, toRefs, onMounted, reactive, inject } from "vue";
import { useRouter } from "vue-router";
let router = useRouter();
const injectMessage = inject("$message");
// import { useUserStore } from "@/stores/user";
// let userStore = useUserStore();
// let { userInfo } = toRefs(userStore);

onMounted(() => {
  getData();
});
// 获取会员详细信息
let userInfo = reactive({});
function getData() {
  post661f7a29c8ae2({})
    .then((res) => {
      if (res.code == 1) {
        userInfo = Object.assign(userInfo, res.data);
      }
    })
    .catch((err) => {
      console.log(err);
    });
}
// 修改手机号
function editPhone() {
  router.push({
    path: "/setUp/changePhone",
  });
}
function editPassword() {
  router.push({
    path: "/setUp/changePsd",
  });
}
function unbindWechat() {
  console.log("解绑微信");
  post662a30c667004({})
    .then((res) => {
      if (res.code == 1) {
        injectMessage.success(res.msg);
        getData();
      }
    })
    .catch((err) => {
      console.log(err);
    });
}
</script>

<style lang="scss" scoped>
.information {
  padding: 18px 16px;
  background: #fff;
  min-height: 437px;
  .title {
    font-size: 9px;
    font-weight: 500;
    margin: 13px 0;
  }
  .set_cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .set_item {
      width: 267px;
      padding: 10px 12px;
      background: #f6f7f9;
      display: flex;
      align-items: center;
      margin-bottom: 10px;
      .icon {
        width: 24px;
        height: 24px;
        margin-right: 8px;
      }
      .item_text {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .text_le {
          display: flex;
          flex-direction: column;
          justify-content: center;
          .text_le_1 {
            font-size: 8px;
            font-weight: 500;
          }
          .text_le_2 {
            font-size: 7px;
            color: #999;
            // margin-top: 5px;
          }
        }
        .text_ri {
          width: 38px;
          height: 16px;
          background: #1f52ae;
          border-radius: 2px;
          font-size: 7px;
          color: #fff;
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
        }
        .text_ri_unbind {
          width: 38px;
          height: 16px;
          border: 1px solid #bfbfbf;
          background: #fff;
          border-radius: 2px;
          font-size: 7px;
          color: #666;
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
        }
      }
    }
  }
}

.save_btn {
  width: 120px;
  height: 24px;
  background: #1f52ae;
  font-size: 8px;
  color: #fff;
  border-radius: 3px;
  margin: 32px 0 0 47px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
</style>